package com.wu.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author: 吴磊
 * @program: springboot-rabbitmq
 * swagger访问地址：http://localhost:9045/swagger-ui/index.html
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {

    /**
     * 配置了Swagger的Docket 的bean实例
     *
     * @param environment
     * @return
     */
    @Bean
    public Docket docket(Environment environment) {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("springboot-rabbitmq")
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.wu.controller"))
                .build();
    }


    /**
     * 配置Swagger信息  apiInfo
     *
     * @return
     */
    private ApiInfo apiInfo() {
        //作者信息
        Contact DEFAULT_CONTACT = new Contact("springboot-rabbitmq", "https://blog.csdn.net/wulei2921625957", "2921625957@qq.com");
        return new ApiInfo(
                "springboot-rabbitmq的API文档",
                "",
                "3.0",
                "https://blog.csdn.net/wulei2921625957",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList());
    }
}

